Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coam-client

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coam-client

A thin client for COAM service

  • 0.1.16
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

COAM thin client

A thin client to perform certain requests in COAM. This is not an exhaustive implementation of COAM API.

If you like to add a method (or tweak something), please open a pull-request. We love pull-requests! But we also love solving issues, so in case you don't really have the time for a pull-request right now, maybe you can just tell us what you'd like?

Or maybe you just feel like writing us a mail? Yes, you guessed right, we also love reading mails ;)

CoamClient class

A simple client to make API calls to COAM. It has a few additional features that can be controlled by the options parameter passed in the constructor.

const client = new CoamClient(options);
Accepted options are:
  • accessToken (required) - The access token to use to authenticate the API calls
  • baseUrl - Base COAM API URL. Defaults to https://api.cimpress.io
  • retryAttempts - How many tries to retry the requests in case of failure*. Defaults to 2.
  • retryDelayInMs - How many milliseconds to wait between retires. Defaults to 200.
  • retryOnForbidden - A flag specifying if a retry has to be performed in case of 'Forbidden' response. Defaults to 'true'
  • debugFunction - A function to call to provide debug information. Defaults to none.
  • errorFunction - A function to call on error. Defaults to console.err;
  • timeout - A value setting the timeout of the underlying HTTP calls to COAM. Defaults to 10000 (10 seconds). Set it to 0 for no timeout.
Provided methods
  • buildGroupUrlFromId(groupId)
  • hasPermission(principal, resourceType, resourceIdentifier, permission)
  • grantRoleToPrincipal(groupUrl, principal, roleName)
  • getGroupInfo(groupUrl)
  • setAdminFlag(groupId, principal, isAdmin)
  • removeUserRole(groupId, principal, role)
  • addUserRole(groupId, principal, role)
  • modifyUserRoles(groupId, principal, rolesChanges)
  • addGroupMember(groupId, principal, isAdmin)
  • removeGroupMember(groupId, principal)
  • getRoles()
  • findPrincipals(query)
  • createGroup(name, description)
  • getPrincipal(accessToken, principal)
  • removeGroup(groupId)
  • findGroups(resourceType, resourceIdentifier)
  • removeResourceFromGroup(groupId, resourceType, resourceId)
  • addResourceToGroup(groupId, resourceType, resourceId)
  • getUserPermissionsForResourceType(principal, resourceType)
  • getUsersWithPermission(resourceType, resourceIdentifier, permission)
  • createGroupWithUser(principalToCreateGroup, principalToAddToGroup, groupName, groupDescription, rolesToAdd, resourcesToAdd)
Direct helper functions

In some cases, it is easier to simply call a function to perform the required action without the need for creating a specific client. The following helper methods satisfy these needs by creating a default client and performing the necessary requests.

Here is a list of helpers (name + required parameters):

  • buildGroupUrlFromId(groupId)
  • hasPermission(accessToken, principal, resourceType, resourceIdentifier, permission)
  • grantRoleToPrincipal (accessToken, groupUrl, principal, roleName)
  • getGroupInfo (accessToken, groupUrl)
  • setAdminFlag (accessToken, groupId, principal, isAdmin)
  • removeUserRole (accessToken, groupId, principal, role)
  • addUserRole (accessToken, groupId, principal, role)
  • modifyUserRoles (accessToken, groupId, principal, rolesChanges)
  • addGroupMember (accessToken, groupId, principal, isAdmin)
  • removeGroupMember (accessToken, groupId, principal)
  • getRoles (accessToken)
  • findPrincipals (accessToken, query)
  • getPrincipal (accessToken, principal)
  • createGroup (accessToken, name, description)
  • removeGroup (accessToken, groupId)
  • findGroups (accessToken, resourceType, resourceIdentifier)
  • removeResourceFromGroup (accessToken, groupId, resourceType, resourceId)
  • addResourceToGroup (accessToken, groupId, resourceType, resourceId)
  • getUserPermissionsForResourceType (accessToken, principal, resourceType)
  • getUsersWithPermission (accessToken, resourceType, resourceIdentifier, permission)
  • createGroupWithUser (accessToken, principalToCreateGroup, principalToAddToGroup, groupName, groupDescription, rolesToAdd, resourcesToAdd)

Important: All helper methods are using the CoamClient class with default settings (see above).

Keywords

FAQs

Package last updated on 10 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc